Skip to content

Extend scheme validation to inner schemes of jar: URLs#636

Merged
garydgregory merged 7 commits into
masterfrom
fix/file-location-strategy-protocols
May 12, 2026
Merged

Extend scheme validation to inner schemes of jar: URLs#636
garydgregory merged 7 commits into
masterfrom
fix/file-location-strategy-protocols

Conversation

@ppkarwasz
Copy link
Copy Markdown
Member

Builds on #633 by recursively validating the inner URL of a jar: URL against the same scheme and host allow-lists.

This deliberately changes the previous semantics: for jar:http://host/... to be accepted, both jar and http must appear in the allow-list, and the inner host must satisfy the host allow-list.

An alternative considered was the grammar documented by XMLConstants, where tokens like jar:file or jar:http would explicitly allow specific inner schemes. That grammar is documented but not honored by the JDK reference implementation: jdk.xml.internal.SecuritySupport.checkAccess (verified on JDK 8, 17 and 25) strips the jar: prefix and matches only the inner scheme as a bare token, so a jar:http entry in the allow-list never matches anything. Aligning with the documented spec would have added marginal expressiveness at the cost of diverging from what JDKs actually do.

ppkarwasz added 4 commits May 12, 2026 12:32
Builds on #633 by recursively validating the inner URL of a jar: URL against the same scheme and host allow-lists.

This deliberately changes the previous semantics: for `jar:http://host/...` to be accepted, both `jar` and `http` must appear in the allow-list, and the inner host must satisfy the host allow-list.

An alternative considered was the grammar documented by
[`XMLConstants`](https://docs.oracle.com/en/java/javase/25/docs/api/java.xml/javax/xml/XMLConstants.html),
where tokens like `jar:file` or `jar:http` would explicitly allow specific inner schemes. That grammar is documented but not honored by the JDK reference implementation: `jdk.xml.internal.SecuritySupport.checkAccess`
(verified on JDK 8, 17 and 25) strips the `jar:` prefix and matches only the inner scheme as a bare token, so a `jar:http` entry in the allow-list never matches anything. Aligning with the documented spec would have added
marginal expressiveness at the cost of diverging from what JDKs actually do.
The classical inversion bug. 😉
Copy link
Copy Markdown
Member

@garydgregory garydgregory left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR @ppkarwasz

  • I think I saw some failures fly by on Java 25 due, possibly, to different Java versions throwing different exceptions for missing hosts.
  • I left comments scattered throughout.
    Thank you!

@garydgregory garydgregory merged commit d14950e into master May 12, 2026
8 of 9 checks passed
@garydgregory garydgregory deleted the fix/file-location-strategy-protocols branch May 12, 2026 11:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants